package com.codegeek.project.slope.service.impl;

import com.codegeek.common.utils.DateUtils;
import com.codegeek.project.slope.domain.SlopeTarget;
import com.codegeek.project.slope.mapper.SlopeTargetMapper;
import com.codegeek.project.slope.service.ISlopeTargetService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 监测目标Service业务层处理
 *
 * @author codegeek
 * @date 2020-02-17
 */
@Service
public class SlopeTargetServiceImpl implements ISlopeTargetService {
    @Autowired
    private SlopeTargetMapper slopeTargetMapper;

    /**
     * 查询监测目标
     *
     * @param targetId 监测目标ID
     * @return 监测目标
     */
    @Override
    public SlopeTarget selectSlopeTargetById(Long targetId) {
        return slopeTargetMapper.selectSlopeTargetById(targetId);
    }

    /**
     * 查询监测目标列表
     *
     * @param slopeTarget 监测目标
     * @return 监测目标
     */
    @Override
    public List<SlopeTarget> selectSlopeTargetList(SlopeTarget slopeTarget) {
        return slopeTargetMapper.selectSlopeTargetList(slopeTarget);
    }

    /**
     * 新增监测目标
     *
     * @param slopeTarget 监测目标
     * @return 结果
     */
    @Override
    public int insertSlopeTarget(SlopeTarget slopeTarget) {
        slopeTarget.setCreateTime(DateUtils.getNowDate());
        return slopeTargetMapper.insertSlopeTarget(slopeTarget);
    }

    /**
     * 修改监测目标
     *
     * @param slopeTarget 监测目标
     * @return 结果
     */
    @Override
    public int updateSlopeTarget(SlopeTarget slopeTarget) {
        slopeTarget.setUpdateTime(DateUtils.getNowDate());
        return slopeTargetMapper.updateSlopeTarget(slopeTarget);
    }

    /**
     * 批量删除监测目标
     *
     * @param targetIds 需要删除的监测目标ID
     * @return 结果
     */
    @Override
    public int deleteSlopeTargetByIds(Long[] targetIds) {
        return slopeTargetMapper.deleteSlopeTargetByIds(targetIds);
    }

    /**
     * 删除监测目标信息
     *
     * @param targetId 监测目标ID
     * @return 结果
     */
    @Override
    public int deleteSlopeTargetById(Long targetId) {
        return slopeTargetMapper.deleteSlopeTargetById(targetId);
    }
}
